package com.tanhua.controller;

import com.tanhua.domain.vo.RecommendUserQueryVO;
import com.tanhua.service.RecommendUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/tanhua")
public class TanHuaController {
    @Autowired
    private RecommendUserService recommendUserService;

    /**
     * GET/tanhua/todayBest
     * 推荐今日佳人
     */
    @GetMapping("/todayBest")
    public ResponseEntity todayBest(){
        return recommendUserService.todayBest();
    }

    /**
     * GET/tanhua/recommendation
     * 首页推荐
     */

    @GetMapping("/recommendation")
    public ResponseEntity recommendation(RecommendUserQueryVO queryVO){
        return recommendUserService.recommendation(queryVO);
    }

    /**
     * GET/tanhua/:id/personalInfo
     * 佳人信息
     */
    @GetMapping("/{id}/personalInfo")
    public ResponseEntity personalInfo(@PathVariable("id") Long targetUserId){
        return recommendUserService.personalInfo(targetUserId);
    }

    /**
     * GET/tanhua/strangerQuestions
     * 查询陌生人问题
     */
    @GetMapping("/strangerQuestions")
    public ResponseEntity strangerQuestions(Long userId){
       return recommendUserService.strangerQuestions(userId);
    }

    /**
     * POST/tanhua/strangerQuestions
     * 回答陌生人问题
     */
    @PostMapping("/strangerQuestions")
    public ResponseEntity answerQuestions(@RequestBody Map map){
        Long userId = Long.parseLong(map.get("userId").toString());
        String reply = (String) map.get("reply");
        return recommendUserService.answerQuestions(userId,reply);
    }
    /**
     * GET/tanhua/search
     * 搜附近
     */
    @GetMapping("/search")
    public ResponseEntity search(String gender,Integer distance){
        return recommendUserService.search(gender,distance);
    }
}
